package edu.kjxy.worker0322;

import java.util.Scanner;

public class worker07 {

	public static void main(String[] args) {
		int[] monthdays = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		
		Scanner in = new Scanner(System.in);
		
		int year = in.nextInt();
		int days = in.nextInt();
		in.close();
		
		if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
			monthdays[2] += 1;
		}
		int i = 1;
		while(days > 0) {
			days -= monthdays[i++];
		}
		System.out.println((i - 1) + "月" + (days + monthdays[i - 1]) + "号");
	}

}
